package dao.Impl;

import dao.ClassDao;
import po.Class;
import po.Grade;
import service.ClassService;
import util.DBUtils;
import util.DaoRepeat;

import java.sql.SQLException;
import java.util.List;

public class ClassDaoImpl extends BaseDaoImpl<Class> implements ClassDao {
    @Override
    public boolean insert(Class c) {
        try {
            insert(c, DBUtils.getConnection());
        } catch (SQLException e) {
            e.printStackTrace();
        }return  true;
    }

    @Override
    public boolean delete(Class c) {
        try {
            delete(c,DBUtils.getConnection());
        } catch (SQLException e) {
            e.printStackTrace();
        }return  true;
    }

    @Override
    public boolean update(Class c) {
        try {
            update(c,DBUtils.getConnection());
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return  true;
    }

    @Override
    public Class queryOne(Integer id) {
        Class aClass = queryOne("select * from Class where id=?", Class.class, id);
        return  aClass;
    }

    @Override
    public List<Class> queryAll(Integer gid) {
        List<Class> classes = queryMany("select * from Class where gid=?", Class.class, gid);
        return classes;
    }




}
